package top.chendawei.aop.bus;

import com.google.common.eventbus.Subscribe;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import top.chendawei.system.beans.entity.OperationLog;
import top.chendawei.system.service.ICommonService;
import top.chendawei.util.thread.ThreadPool;

@Slf4j
@Component
public class GuavaLogEvent {
    @Autowired
    private ICommonService commonService;

    @Subscribe
    public void subscribe(OperationLog oplog) {
        //操作日志根据需要可以选择异步处理
        ThreadPool.exec(new Runnable() {
            @Override
            public void run() {
                try {
                    commonService.commonAdd(oplog);
                } catch (Exception e) {
                    log.error("", e);
                }
            }
        });
    }

}
